package com.tadpole.music.holder.home;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.me.MemberCenterBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.utils.NoDoubleClickListener;

import java.util.List;

/**
 * Created By 孙岩
 * on 2020/9/12
 */
public class SchoolGradeViewHolder extends BaseViewHolder {
    private View itemView;
    private BaseAdapter.OnItemClickListener onItemClickListener;
    private List<MemberCenterBean.DataBean.GoodsBean> goodsBean;
    private TextView tvName;
    private Activity activity;

    public SchoolGradeViewHolder(Activity activity,View itemView,BaseAdapter.OnItemClickListener onItemClickListener,List<MemberCenterBean.DataBean.GoodsBean> goodsBean) {
        super(itemView);
        this.itemView = itemView;
        this.activity  = activity;
        this.onItemClickListener = onItemClickListener;
        this.goodsBean = goodsBean;
    }

    @SuppressLint("UseCompatLoadingForDrawables")
    @Override
    public void init(final int position) {
        tvName = itemView.findViewById(R.id.tvName);

        if(position==0){
            tvName.setBackground(activity.getResources().getDrawable(R.drawable.shape_1_line));
        }else if(position==1){
            tvName.setBackground(activity.getResources().getDrawable(R.drawable.shape_2_line));
        }else if(position==2){
            tvName.setBackground(activity.getResources().getDrawable(R.drawable.shape_3_line));
        }else if(position==3){
            tvName.setBackground(activity.getResources().getDrawable(R.drawable.shape_4_line));
        }else if(position==4){
            tvName.setBackground(activity.getResources().getDrawable(R.drawable.shape_5_line));
        }else if(position==5){
            tvName.setBackground(activity.getResources().getDrawable(R.drawable.shape_6_line));
        }

        tvName.setText(goodsBean.get(position).getRank().getName());
        itemView.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onItemClickListener.onItemClick(itemView,position);
            }
        });
    }
}
